//
//  ZXZTabbarViewController.m
//  zuxianzhi
//
//  Created by tyu on 27.5.24.
//

#import "ZXZTabbarViewController.h"
#import "ZXZNavViewController.h"
#import "ZXZHomeViewController.h"
#import "ZXZGowuViewController.h"
#import "ZXZMyViewController.h"

@interface ZXZTabbarViewController ()

@end

@implementation ZXZTabbarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];

    [self BAC_addUI];
}


-(void)BAC_addUI{

    UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, -20, [UIScreen mainScreen].bounds.size.width, 108)];
    backView.backgroundColor = [UIColor whiteColor];
    [self.tabBar addSubview:backView];

    ZXZNavViewController *homeVC=[[ZXZNavViewController alloc] initWithRootViewController:[[ZXZHomeViewController alloc]init]];
    [self bacSetUpOneChildVcWithVc:homeVC Image:@"tabbar_home" title:@"首页"];

    ZXZNavViewController *BorrowVC=[[ZXZNavViewController alloc] initWithRootViewController:[[ZXZGowuViewController alloc]init]];
    [self bacSetUpOneChildVcWithVc:BorrowVC Image:@"tabbar_gowu" title:@"购物车"];

    ZXZNavViewController *myVC=[[ZXZNavViewController alloc] initWithRootViewController:[[ZXZMyViewController alloc]init]];
    [self bacSetUpOneChildVcWithVc:myVC Image:@"tabbar_my" title:@"我的"];

    self.viewControllers = @[homeVC,BorrowVC,myVC];
}

- (void)bacSetUpOneChildVcWithVc:(ZXZNavViewController *)Vc Image:(NSString *)image  title:(NSString *)title {

    Vc.tabBarItem.image=[[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    Vc.tabBarItem.selectedImage=[[UIImage imageNamed:[NSString stringWithFormat:@"%@_sel",image]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];

    Vc.tabBarItem.title = title;

    // 设置 tabbarItem 选中状态下的文字颜色(不被系统默认渲染,显示文字自定义颜色)
    NSDictionary *dictHome = [NSDictionary dictionaryWithObject:[UIView ColorWithHexString:@"#07C6D2"] forKey:NSForegroundColorAttributeName];
//    NSDictionary *dictHome = [NSDictionary dictionaryWithObject:[UIColor redColor] forKey:NSForegroundColorAttributeName];

    [Vc.tabBarItem setTitleTextAttributes:dictHome forState:UIControlStateSelected];
    NSDictionary *NormalDictHome = [NSDictionary dictionaryWithObject:[UIColor blackColor] forKey:NSForegroundColorAttributeName];
    [Vc.tabBarItem setTitleTextAttributes:NormalDictHome forState:UIControlStateNormal];

}


@end
